package com.baidu.dao;

import java.util.ArrayList;
import java.util.List;

import com.baidu.enetity.Peilvbiao;


import jpersist.DatabaseManager;
import jpersist.JPersistException;
import jpersist.Result;

public class peilvDao {
	DatabaseManager dbm= Connection.getDatabaseManager();
	public List<Peilvbiao> selectPeilv(){
		List<Peilvbiao> li=new ArrayList<Peilvbiao>();
		try {
			Result<Peilvbiao> rs=dbm.getDatabase().queryObject(Peilvbiao.class);
			for (Peilvbiao peilvbiao : rs) {
				li.add(peilvbiao);
			}
		} catch (JPersistException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return li;
	}
	public Peilvbiao findById(int id){
		Peilvbiao p= new Peilvbiao();
		try {
			p = dbm.loadObject(Peilvbiao.class,"where id=?",id);
		} catch (JPersistException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return p;
	}
	public int uppeilvById(int id,Peilvbiao p){
		int	ret=0;
		try {
				ret = dbm.saveObject(p,"where id=?",id);
		} catch (JPersistException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return	ret;
	}
}
